package com.qzh.utils;

public class Chinese {
    public static String numberToChinese(long num) {
        if (num == 0) {
            return "零";
        }

        String[] chineseNums = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
        String[] units = {"", "十", "百", "千","万","十万","百万"};

        StringBuilder sb = new StringBuilder();
        int unitIndex = 0;
        boolean needZero = false;

        while (num > 0) {
            int digit = (int) (num % 10);
            if (digit != 0 || !needZero) {
                sb.insert(0, chineseNums[digit] + units[unitIndex]);
                needZero = true;
            } else {
                needZero = false;
            }
            unitIndex++;
            num /= 10;
        }

        return sb.toString();
    }
}
